new Vue({
  el: '#app',
  data: {   
        //数据
        huabi:{  
			"gaokai":"50",                      //高开钱
			"gaokaishouyibi": "0",         //高开收益比
			"dikai":"50",                       //低开钱  
			"dikaishouyibi":"0",           //低开收益比
            "shoupan":"",    //收盘比
            "month":"6",                        //月份
            "day":"56",                         //日期
            "total":"",                     //奖池钱                        
            "money":"0",                        //用户钱
            "username":"",                      //账户信息
            "ying":"0",                         //盈亏
            "sheng":"0",                        //赢的场数
            "lv":"0",                           //胜率
            "fu":"0",                           //输得场数
            'daoji':'',                        //开盘倒计时
            'daojis':'',                       //收盘倒计时 
            'cai':"哈哈",                          //高或涨
            "cai2":'哈哈',                         //低或跌 
        },
        jie:{
            'jieguo':"涨",                       //结果
            "bili":"1.94",                      //比例
            "qianshu":"1412",                   //钱数
            'time':"16:00"                      //时间
        },
        deta:{
            'userName':'',                     //注册账户
            'userPass':'',                     //注册密码
            'userPassword':"",                 //注册第二次密码
            'userYan':"",                       //验证码
            'userYao':''                        //邀请码
        },
        deta_log:{
            'username':'',                     //登录账户
            'userpassword':"",                 //登录密码
        },
        cun_deta:{
            "name":"",                         //存储账户
            "uid":"",                           //存储id
            "password":""                      //存储密码
        },
        // 忘记密码
        fort_deta:{
            'name':"",                          //忘记密码账户
            'pass':"",                         //忘记密码密码
            'password':"",                      //忘记密码密码  
            'ma':'',                           //忘记密码验证码                 
        },
        // 兑换记录
        jilu_deta:{
            'dingName':'',   //姓名
            'dingIphone':'', //电话
            'dingBian':'', //邮编
            'dingDi':'', //地址
            'dingXiang':'', //详细地址
            'dingId':'',
        },


        // 状态显示
        // home页
        isDate:false,                           //猜开盘高低
        isDao:false,                            //看开盘人
        isKai_jie:false,                         //结果
        isTurn:false,                           //猜收盘涨跌
        isTurns:false,                          //收盘关闭

        GKM:'',                                 //高开押注金额
        DKM:'',                                 //低开押注金额
        // 个人中心页面
        isHiden:false,                           //已登录
        isShow:false,                           //未登录
        isShou:true,                            //收盘
        isKai:false,                            //开盘

        data_hous:new Date().getHours(),        //小时
        data_mouth:new Date().getMinutes(),     //分钟
        data_second:new Date().getSeconds(),    //小时
       
        pageNo: 1,                              //兑换信息地址


        data_shop:[],                           //兑换商品信息
        data_jilu:[],                           //兑换记录
        data_items:[],                          //个人中心收盘
        data_itemk:[],                          //个人中心开盘
        zhang:localStorage.getItem("zhang"),
        mi:localStorage.getItem('mi')
  },
  mounted() {
        // this.setDate();                         //时间判断
        this.dataShop();
        this.shua();                            //注册页面和忘记密码页面用到的验证码
        this.people();                          //个人中信息请求  保存了用户名，id，钱数
        setInterval(this.HomeData,3000);      //首页股票信息
        this.HomeData();
        this.HomeData_cai();
        this.HomeData_Day();                      //时间  
  },
  methods:{   //方法
        gaokai:function(e){   
             e.preventDefault();                //显示高开视图
             this.HomeData();
             $(".screen").css("display","block");
             
        },
        dikai:function(e){      
             e.preventDefault();     //显示低开视图
             this.HomeData();                  
             $(".screens").css("display","block");
        },      
        back:function(e){                              //关闭视图
             e.preventDefault();
             $(".screen").css("display","none");
             $(".screens").css("display","none");
            //  location.reload(true);
        },
        //默认下注钱数  
        // 收盘下注
        si:function(e){                                //下注钱数
            e.preventDefault();
            this.GKM='50';
            // $(".gao_money").val(50);
        },
        ban:function(e){
             e.preventDefault();
            // $(".gao_money").val(100);
            this.GKM='100';
        },
        man:function(e){
             e.preventDefault();
            //  $(".gao_money").val(500);
            this.GKM='500';
        },
        // 开盘下注
        sis:function(e){
             e.preventDefault();
             this.DKM='50';
            // $(".gao_moneys").val(50);
        },
        bans:function(e){
             e.preventDefault();
            // $(".gao_moneys").val(100);
             this.DKM='100';
        },
        mans:function(e){
             e.preventDefault();
            //  $(".gao_moneys").val(500);
             this.DKM='500';
        }, 
        //个人中心
        opinion:function(){
            
            for(var k in this.data_items){
                
               
                if( this.data_items[k].CHwin == '胜'){
                  
                    // console.log(true);
                }else{
                    // console.log(false);
                    
                }
            }
        }, 
        //买高开 
        reqGk:function(e){
             e.preventDefault();                       //高开下注
               var that = this;  
             if(this.cun_deta.uid==''||this.cun_deta.uid==null){
                alert('您好，请先登录账户!!');
                window.location.href="index.html";
             }else{
                //  console.log('下注金额'+this.GKM);
                //  console.log('id'+this.cun_deta.uid);
                $.ajax({
                    url:'http://118.31.79.20:8080/Stock/share/shareUpOrDown.do',
                    type: "post",
                    dataType: 'json',
                    data:{'userid':this.cun_deta.uid,'money':this.GKM,'upordown':1},
                    success:  function(data) {
                        // console.log('下注金额'+this.GKM);
                        // console.log('状态'+data.success);
                        // console.log('状态会话'+data.msg);
                        that.people();
                        $(".screen").css("display","none");
                        // location.reload(true);
                    },
                    error:function(error){
                        alert("注册"+error);
                    }
                })
               
             }
        },
        //买低开 
        reqDk:function(e){                            //低开下注
             e.preventDefault();  
             var that = this;  
            //  console.log('低开下注金额'+this.DKM);
            $.ajax({
                    url:'http://118.31.79.20:8080/Stock/share/shareUpOrDown.do',
                    type: "post",
                    dataType: 'json',
                    data:{'userid':this.cun_deta.uid,'money':this.DKM,'upordown':0},
                    success: function (data) {
                        // console.log('状态'+data.success);
                        // console.log('状态会话'+data.msg);
                        that.people();
                        $(".screens").css("display","none");
                        
                    },
                    error:function(error){
                        alert("注册"+error);
                    }
                })   
            // axios.post('http://118.31.79.20:8080/Stock/share/shareUpOrDown.do',{'userid':this.cun_deta.uid,'money':this.DKM,'upordown':1})
            //           .then((response)=>{
            //                 console.log('下注金额'+this.DKM);
            //                 console.log('状态'+response.data.success);
            //                 console.log('状态会话'+response.data.msg);
            //           })
            //           .catch((error)=>{

            //           })               
            
        },
        setDate:function(){                         //时间
            // if( 10 <= this.data_hous && this.data_hous < 13 ){
            // this.isDate = true;
            // // if(this.data_hous == 13 && this.data_mouth ==0 && this.data_second == 0 ){
            // //   this.huabi.total = localStorage.getItem("total");
            // //   this.huabi.gaokaishouyibi = localStorage.getItem("gao");
            // //   this.huabi.dikaishouyibi = localStorage.getItem("di");
            // // }
            // }else{
            //     // console.log(true)
            //     this.isDao=true;
            //      this.isDate = true;
            // }
        },
        closes:function(){                      //收盘记录数据
             this.isShou=true;                        
             this.isKai=false;
        },
        open:function(){                        //开盘记录数据
            this.isShou=false;
            this.isKai=true;
        },
        chong:function(e){
            e.preventDefault();
            window.location.href="chong.html";
        },
        jilu:function(e){
            e.preventDefault();
            window.location.href="jilu.html";
                                      
        },
        tui:function(e){
            e.preventDefault();
            localStorage.clear();
            this.cun_deta.uid='';
            this.huabi.username='';
            this.huabi.money='';
            window.location.href="index.html";
        },
        dataShop:function(){                       //兑换商品信息           
             var that = this; 
                axios.get('http://118.31.79.20:8080/Stock/product/findProductList.do?pageNo='+this.pageNo)
                     .then(function(response){
                            // console.log('商品信息'+response.data.currentPageDatas);
                            let data_list = response.data.currentPageDatas;//商品信息
                            for(var  k in data_list){
                                // 把商品信息存进数组里面
                                // console.log('图片'+data_list[k].thumb);
                                that.data_shop.push(data_list[k]);
                            }
                     })
                     .catch(function(error){

                     })

        },
        iphone:function(event){                          //手机号验证         
            // 手机号正则验证
            let regTel = /^0?1[3|4|5|8][0-9]\d{8}$/;
            if(!regTel.test(event)){
                
                alert("您好，账号格式不正确!!");
                return false;
            }else{
                return true;
            }
        },
        passw:function(event){                           //密码验证
            let iph = /^(?!(?:\d*$))[A-Za-z0-9]{6,20}$/;
            if(!iph.test(event)){
                
                alert("您好，密码格式不正确!!");
                return false;
            }else{
                return true;
            }
        },
        yma(event){                                      //验证码验证
                let mas = $(".yan").text();
                // console.log(mas);
                if(event != mas){
                
                    alert("验证码错误!!");
                    return false;
                }else if(event == '' || event ==null){
                
                    alert("验证码不能为空!!");
                    return false;
                }else{
                    return true;
                }

        }, 
        //更换验证码 
        ma:function(e){
                e.preventDefault();
                // $.ajax({
                //     url:'http://118.31.79.20:8080/Stock/code/getCode.do',
                //     type: "get",
                //     dataType:'json',
                //     data: '',
                //     success: function (data) {
                //         var result = data.data; //验证码
                //         // alert("验证码"+datass.data);
                //         var autoRandom =document.querySelector(".yan");
                //         autoRandom.innerHTML=result;
                //     },
                //     error:function(){
                //         console.log(error)
                //     }
                    
                // })
                 axios.get('http://118.31.79.20:8080/Stock/code/getCode.do')
                        .then( function(response) {
                              var result = response.data.data
                              var autoRandom =document.querySelector(".yan");
                              autoRandom.innerHTML=result;
                        })
                        .catch(function (error) {
                            // console.log(error);
                        });
        },
        //注册 
        li:function(e){

            e.preventDefault();
             if(this.deta.userName == "" || this.deta.userName == null || this.deta.userPass == "" || this.deta.userPass == null || this.deta.userPassword == "" || this.deta.userPassword == null){
                alert("您好，账户和密码不能为空");
                return false;                
            }else if(this.deta.userPass != this.deta.userPassword){
                alert("您好，两次密码输入不一致!!");
                return false;
            }else if(this.iphone(this.deta.userName) && this.passw(this.deta.userPass)&& this.yma(this.deta.userYan)){
                $.ajax({
                    url:'http://118.31.79.20:8080/Stock/login/register.do',
                    type: "post",
                    dataType: 'json',
                    data: {"mobile":this.deta.userName,"password":this.deta.userPassword,'yqm':this.deta.userYao},
                    success: function (data) {
                    if(data.flag){    //成功跳转等页面
                            alert("注册成功，请登录!!");
                            window.location.href="index.html";
                        }else{
                            alert(data.data);
                            return false;
                        }
                    },
                    error:function(error){
                        alert("注册"+error);
                    }
                })
                    // axios.post('http://118.31.79.20:8080/Stock/login/register.do',{"mobile":this.deta.userName,"password":this.deta.userPassword,'yqm':this.deta.userYao})
                    //     .then( (response) =>{
                    //         console.log(this.deta.userName);
                    //           if(response.data.flag){    //成功跳转等页面
                    //                 alert("注册成功，请登录!!");
                    //                 window.location.href="index.html";
                    //           }else{
                    //                 alert(response.data.data);
                    //                 return false;
                    //           }
                    //     })
                    //     .catch( (error) =>{
                    //         console.log(error);
                    //     });
            }
            
        },
        // 刷新
        shua:function(){
          
            // $.ajax({
            //         url:'http://118.31.79.20:8080/Stock/code/getCode.do',
            //         type: "get",
            //         dataType:'json',
            //         data: '',
            //         success: function (data) {
            //             var result = data.data; //验证码
            //             // alert("验证码"+datass.data);
            //             var autoRandom =document.querySelector(".yan");
            //             autoRandom.innerHTML=result;
            //         },
            //         error:function(error){
            //             console.log(error)
            //         }
            // });    

            axios.get('http://118.31.79.20:8080/Stock/code/getCode.do',)
                 .then( function(response) {
                         var result = response.data.data
                         var autoRandom =document.querySelector(".yan");
                         autoRandom.innerHTML=result;
                 })
                 .catch( function(error) {
                    console.log(error);
                 });            
        },   
        // 登录
        login:function(e){
                var that = this;
                e.preventDefault();
                var iphone = /^0?1[3|4|5|8][0-9]\d{8}$/;
                if(this.deta_log.username == '' || this.deta_log.username == null || this.deta_log.userpassword ==''||this.deta_log.userpassword == null){
                
                    alert("您好，请输入账号名和密码!!");
                    return false;
                }else if(!iphone.test(this.deta_log.username)){
                    alert("您好，账户格式不正确!!");
                    return false;
                }else{
                    $.ajax({
                        url:'http://118.31.79.20:8080/Stock/login/login.do',
                        type: "post",
                        dataType: 'json',
                        data: {"username":this.deta_log.username,"password":this.deta_log.userpassword},
                        success: function(data){
                           
                            if(data.flag){    //成功跳转等页面
                                localStorage.setItem('zhang',that.deta_log.username);
                                localStorage.setItem('mi',that.deta_log.userpassword)
                                window.location.href="home.html";
                                             
                               
                            }else{
                                alert("您好，账户或密码不正确！");
                                return false;
                            }
                        },
                        error:function(error){
                            // alert("登录"+error);
                        }
                    })
                };
        },    
        // 个人信息
        people:function(){
             var that = this;
                axios.get("http://118.31.79.20:8080/Stock/login/login.do?username="+this.zhang+'&&password='+this.mi)
                .then( function(response) {
                    // console.log('用户名'+response.data.data.username);
                    // console.log('用户id'+response.data.data.uid);
                    // console.log('用户钱数'+response.data.data.money);
                    that.huabi.username=response.data.data.username;//用户名
                    that.cun_deta.uid=response.data.data.uid;//用户id
                    that.huabi.money=response.data.data.money;//用户钱数
                    // console.log('用户id'+this.cun_deta.uid);
                    // console.log('用户钱数'+this.huabi.money);
                    that.AboutDeta();                     //个人中心执行
                    that.Ji();                           //兑换记录
                    that.HomeData_tol();                //首页奖池信息
                })
                .catch(function (error) {
                    console.log(error);
                });
        },
        //忘记密码1
        forgot:function(){
                var that = this;
                if(this.fort_deta.name == "" || this.fort_deta.name == null || this.fort_deta.ma =='' || this.fort_deta.ma==null ){
                    alert("您好，账户和验证码不能为空!");
                    return false;
                }else if(this.iphone(this.fort_deta.name) && this.yma(this.fort_deta.ma)){
                    $.ajax({
                        url:'http://118.31.79.20:8080/Stock/login/forgetPwd.do',
                        type: "post",
                        dataType: 'json',
                        data: {"mobile":this.fort_deta.name},
                        success: function(data) {

                            // 返回状态成功    手机号存在可以修改
                            if(data.flag){    //成功跳转等页面
                                //如果成功吧手机号存在localstrage，在下一个页面取出来
                                localStorage.setItem("useriphone",that.fort_deta.name);
                                window.location.href='forgot1.html';
                            }else{
                                alert('您好，用户名不存在！！');
                                return false;
                            }
                        },
                        error:function(error){
                            alert("注册"+error);
                        }
                    })

                }
        },
        forgot2:function(){
           
            console.log(1);
            // 判断密码是否为空
             if(this.fort_deta.pass=="" || this.fort_deta.pass == null ||this.fort_deta.password =="" || this.fort_deta.password== null){
                 alert("您好，密码不能为空！！");
             }else if(this.fort_deta.pass !=  this.fort_deta.password){
                 alert('您好，两次密码不一致！！');
             }else if(this.passw(this.fort_deta.password)){
                 $.ajax({
                        url:'http://118.31.79.20:8080/Stock/login/updatePwdByMobile.do',
                        type: "post",
                        dataType: 'json',
                        data: {"mobile":localStorage.getItem('useriphone'),"password":this.fort_deta.password},
                        success: function(data){

                            // 返回状态成功    手机号存在可以修改
                            if(data.flag){    //成功跳转登录页面
                                window.location.href='index.html';
                            }else{
                                alert('您好，用户名不存在！！');
                                return false;
                            }
                        },
                        error:function(error){
                            alert("注册"+error);
                        }
                })

             }
        },    
        // 首页信息
        HomeData:function(){
                // console.log(2);
                 var that = this;
                axios.get('http://118.31.79.20:8080/Stock/share/shareInfo.do')
                    .then( function(response) {
                        // console.log('第一数'+response.data.nowpri);
                        // console.log('第二数'+response.data.increase);  
                        // console.log('第三数'+response.data.increPer);
                        let nowpri = response.data.nowpri;        //第一个数
                        let increase = response.data.increase;   //第二个数
                        let increPer = response.data.increPer;   //第三个数
                        if(increase >0){
                            increase = '+' + ''+increase;
                            $(".date_dw").css("color","red");
                        }else{
                            $(".date_dw").css("color","green");
                        }
                        if(increPer >0){
                            increPer='+'+''+increPer;
                        }    
                        that.huabi.shoupan=''+nowpri+''+increase+''+increPer;
                        that.HomeData_cai();
                    })
                    .catch(function(error) {
                        console.log(error);
                    });     
        },
        //时间
        HomeData_Day:function(){
             // 获取年月日
                var myData=new Date();//当前的事件
                var mm=myData.getMonth() + 1;
                if(mm<10){
                var m ='0'+mm;
                }
                var dd= myData.getDate();
                if(dd < 10){
                var d = '0'+ dd;
                }
                if(this.data_hous >= 16){
                d = String(Number(d)+1);
                if(Number(d) < 10){
                    d = '0' + d;
                }
                }
                this.huabi.month=m;
                this.huabi.day=d;
                // console.log('日期'+d)  
        }, 
        //首页的奖池信息
        HomeData_tol:function(){
             var that =this;
                axios.get('http://118.31.79.20:8080/Stock/share/shareNumInfo.do')
                     .then(function(response){
                        // console.log('首页上'+response.data.up);
                        // console.log('首页下'+response.data.down);
                        // 如果有买的钱数
                        if(response.data.up > 0 || response.data.down > 0){
                            // 总奖池的钱
                            let zong = response.data.up + response.data.down;
                            //状态条的高度
                            that.huabi.gaokai=(((response.data.up/(zong))*100).toFixed(2)).toString();  //高开的进度条
                            that.huabi.dikai=(((response.data.down/(zong))*100).toFixed(2)).toString(); //低开的进度条
                            that.huabi.total=response.data.up + response.data.down;
                            // 高开收益比
                            if(response.data.up >0){
                                that.huabi.gaokaishouyibi=(zong/response.data.up).toFixed(2).toString();
                            }else{
                                that.huabi.gaokaishouyibi='0';
                            }
                            // 低开收益比
                            if(response.data.down >0){
                                that.huabi.dikaishouyibi=(zong/response.data.down).toFixed(2).toString()
                            }else{
                                that.huabi.dikaishouyibi='0';
                            }
                        }else{          //没有购买
                             that.huabi.gaokai='0';
                             that.huabi.dikai='0';
                             that.huabi.total='0';
                             that.huabi.gaokaishouyibi='0';
                             that.huabi.dikaishouyibi='0';
                            $(".gaokai").css("width",'50%');
                            $(".dikai").css("width","50%");
                        }
                     })
                     .catch(function(error){
                        alert('网络错误');
                        return false;
                     })
        },
        //切换状态 
        HomeData_cai:function(){
            var that =this;
            axios.get('http://118.31.79.20:8080/Stock/share/html.do')
                .then(function(response){
                    // console.log('状态切换值'+response.data.state);
                    // 状态值 0（开盘结束显示的页面  isDao为真），1（收盘开始显示的页面  isTurn为真），2（收盘结束显示的页面  isTurns为真），
                    // 3（开盘显示的页面  isDate为真），4（开盘结果显示的页面  isKai_jie为真），5（收盘结果显示的页面  isKai_jie为真）
                    // 7（节假日显示的页面  isDate为真）
                    let stat = response.data.state;     //状态值
                    if(stat == 0){
                        // 开盘结束显示的页面  isDao为真
                        // console.log('isDao');
                        that.people(); 
                        that.isDao=true;
                    }else if(stat == 1){
                        // 收盘开始显示的页面  isTurn为真
                        // console.log('isTurn');
                        that.people(); 
                        let e = response.data.date;
                        // console.log('收盘结束时间'+e)
                        setInterval(function(){that.tenTime(e)},500);
                        that.isTurn=true;
                        that.huabi.cai='看涨';
                        that.huabi.cai2='看跌';
                    }else if(stat == 2){
                        // 收盘结束显示的页面  isTurns为真
                        // console.log('isTurns');
                        that.people();      //请求一遍个人信息
                        that.isTurns=true;

                    }else if(stat == 3){
                        // 开盘显示的页面  isDate为真
                        // console.log('isDate');
                        that.people(); 
                        that.isDate=true;
                        let e = response.data.date;
                        setInterval(function(){that.nineTime(e)},500);
                        // console.log('开盘结束时间'+e);
                        that.huabi.cai='高开';
                        that.huabi.cai2='低开';

                    }else if(stat == 4){
                        // 开盘结果显示的页面  isKai_jie为真
                        // console.log('开盘结果isKai_jie');
                        
                        that.jie.time='10:00';
                        that.jie_datas();
                        that.isKai_jie=true;

                    }else if(stat == 5){
                        // 收盘结果显示的页面  isKai_jie为真
                        // console.log('收盘结果isKai_jie');
                        this.jie.time='16:00';
                        this.jie_data();
                        this.isKai_jie=true;
                    

                    }else if(stat == 7){
                        // 节假日显示的页面  isDate为真
                        // console.log('节假日 isDate');
                        that.huabi.cai='高开';
                        that.huabi.cai2='低开';
                        let e = response.data.date;
                        setInterval(function(){that.nineTime(e)},500);
                        // console.log('开盘结束时间'+e); 
                        that.isDate=true;
                    }

                }) 
                .catch(function(error){
                    console.log('状态失败!!');
                })
        }, 
        //收盘请求结果
        jie_data:function(){
            // console.log('用户id'+this.cun_deta.uid);
             var that =this;
            $.ajax({
                url:'http://118.31.79.20:8080/Stock/shareInfoshangqi/shareshangqi.do',
                type: "post",
                dataType: 'json',
                data: {"userid":this.cun_deta.uid},
                success: function(data) {
                    // console.log('结果'+data.yingkui);
                    // console.log('涨'+data.zhangdie);
                    // console.log('比例'+data.bili);
                    if(data.yingkui >0){
                         $('.jie_qianshu').css('color','red');
                    }else{
                         $('.jie_qianshu').css('color','green');
                    }
                    if(data.zhangdie == true){
                        $('.jie_shang_left').css({'color':'#fff','background':'red'});
                        that.jie.jieguo='涨';
                    }else{
                        $('.jie_shang_left').css({'color':'#fff','background':'green'});
                        that.jie.jieguo='跌';
                    }
                    that.jie.qianshu=data.yingkui;   //个人盈亏
                    that.jie.bili=data.bili;        //比例    
                },
                error:function(error){
                    // alert("注册"+error);
                    console.log('请求结果');
                }
            })
        }, 
        // 开盘结果数据s
        jie_datas:function(){
            // console.log('用户id'+this.cun_deta.uid);
             var that =this;
            $.ajax({
                url:'http://118.31.79.20:8080/Stock/shareInfoshangqi/shareshangqi.do',
                type: "post",
                dataType: 'json',
                data: {"userid":this.cun_deta.uid},
                success: function(data) {
                    // console.log('结果'+data.yingkui);
                    // console.log('涨'+data.zhangdie);
                    // console.log('比例'+data.bili);
                    if(data.yingkui >0){
                         $('.jie_qianshu').css('color','red');
                    }else{
                         $('.jie_qianshu').css('color','green');
                    }
                    if(data.zhangdie == true){
                        $('.jie_shang_left').css({'color':'#fff','background':'red'});
                        that.jie.jieguo='高';
                    }else{
                        $('.jie_shang_left').css({'color':'#fff','background':'green'});
                        that.jie.jieguo='低';
                    }
                    that.jie.qianshu=data.yingkui;   //个人盈亏
                    that.jie.bili=data.bili;        //比例    
                },
                error:function(error){
                    // alert("注册"+error);
                    console.log('请求结果');
                }
            })
        }, 
        // 倒计时
        // 9点倒计时
        nineTime(e){
            // console.log('倒计时'+e);  
             var that =this;    
            var startDate=new Date();
            var endDate=new Date(e);
            // console.log("对的"+endDate);
            var countDown=(endDate.getTime()-startDate.getTime())/1000;
            // console.log('数据类型'+typeof((24*60*60)));
        
        
            var h=String(parseInt(String(countDown/(60*60))));
            var m=String(parseInt(String(countDown/60%60)));
            var s=String(parseInt(String(countDown%60)));        
            if(Number(h) < 10){
                h = '0'+h;                
                // console.log(h);
            }
            if(Number(m) < 10){
                m = '0' + m;
            }  
            if(Number(s) < 10){
                s = '0' + s;
            }
                // $('#ten').text(h+'时'+m+'分'+s+'秒');
                that.huabi.daoji=h+'时'+m+'分'+s+'秒';
                // console.log( this.huabi.daoji);
            if(countDown<=0){
                //  $('#ten').text('活动结束'); 
                that.huabi.daoji='活动结束';
            }  
                
        },
        // 10点倒计时
        tenTime(e){
            // console.log('倒计时'+e);
            var that =this;    
            var startDate=new Date();
            var endDate=new Date(e);
            var countDown=(endDate.getTime()-startDate.getTime())/1000;
            // console.log('数据类型'+typeof((24*60*60)));           
            var h=String(parseInt(String(countDown/(60*60)%24)));
            var m=String(parseInt(String(countDown/60%60)));
            var s=String(parseInt(String(countDown%60)));        
            if(Number(h) < 10){
                h = '0'+h;
                // console.log(h);
            }
            if(Number(m) < 10){
                m = '0' + m;
            }  
            if(Number(s) < 10){
                s = '0' + s;
            }
            //  $('#tens').text(h+'时'+m+'分'+s+'秒');
                that.huabi.daojis=h+'时'+m+'分'+s+'秒';
                // console.log(this.huabi.daojis);
            if(countDown<=0){
                // console.log(countDown);
                //  $('#tens').text('活动结束');
                that.huabi.daojis='活动结束';
            }  
        },

        //个人中心数据
        AboutDeta:function(){
            var that =this;    
            // console.log('个人中心');
        //    console.log('用户id'+this.cun_deta.uid);
           if(this.cun_deta.uid==''||this.cun_deta.uid==null){
                this.isShow=true;   //未登录
                this.isHiden=false;  //已登录
           }else{
               this.isShow=false;   //未登录
               this.isHiden=true;  //已登录
               //如果登录则执行 
               axios.get('http://118.31.79.20:8080/Stock/share/shareCenter.do?userid='+this.cun_deta.uid)
                    .then(function(response){
                        // console.log('总盈亏'+response.data.wincount);
                        // console.log('赢得场数'+response.data.win);
                        // console.log('输得场数'+response.data.nwin);
                        // console.log('胜率'+response.data.shenglv);
                        if(response.data.wincount > 0){
                            $('.ying_date').css('color','red');
                        }else{
                            $('.ying_date').css('color','green');
                        }
                        that.huabi.ying=response.data.wincount;//总盈亏
                        that.huabi.sheng= response.data.win;//赢得场数
                        that.huabi.fu=response.data.nwin;//输得场数  
                        that.huabi.lv=response.data.shenglv;//胜率
                        let data_li = response.data.shareList;
                        that.data_items=[];
                        that.data_itemk=[];
                        for( var  k in data_li){
                           
                            if(data_li[k].type==1){
                                
                                that.data_items.push(data_li[k]);
                            }else{
                               
                                that.data_itemk.push(data_li[k]);
                            }
                            
                        
                        }
                        that.opinion(); 
                    })
                    .catch(function(error){
                        console.log('个人中心信息'+error)
                    })
           }     
        },
        //点击兑换
        dui:function(t,m,i){
            var that =this;
            // 判断有没有登录用户id
            if(this.cun_deta.uid==''||this.cun_deta.uid==null){
                alert('您好，请先登录账户！！');
                window.location.href="index.html";
            }else{
               let nu = Number(m);
               let xian = Number(this.huabi.money);
            //    如果钱数少于兑换商品钱数，则跳入充值页面进行充值
                if( nu > xian){           
                    this.mWind("您的牛牛币不足，不能直接兑换");
                    window.location.href="chong.html";
                }else{
                    var mymessage=confirm("是否确认使用"+nu+'枚牛牛币'+t); 
                    if(mymessage==true){
                        //  console.log('兑换用户id'+this.cun_deta.uid);
                        //  console.log('订单id'+i)
                        // axios.post('http://192.168.1.114:8080/Stock/pay/pay.do',{"uid":this.cun_deta.uid,"shopid":i})
                        //      .then((response)=>{
                        //          console.log(this.cun_deta.uid);
                        //          console.log(i);
                        //             console.log('兑换状态码'+response.data.data);
                        //             //兑换成功 
                        //             if(response.data.data == true){
                        //                 alert('兑换成功,请到兑换记录填写地址!');
                        //             }else{
                        //                 alert('兑换失败!');
                        //                 return false;
                        //             }
                        //      })
                        //      .catch((error)=>{

                        //      })
                        
                        $.ajax({
                                url:'http://118.31.79.20:8080/Stock/pay/pay.do',
                                type: "post",
                                dataType: 'json',
                                data:{"uid":this.cun_deta.uid,"shopid":i},
                                success:function (data) {
                                    // console.log(data.flag);
                                    if(data.flag == true){
                                        alert('兑换成功，请到兑换记录填写地址！');
                                        that.people();
                                    }else{
                                        alert('兑换失败！');
                                    }
                                    
                                },
                                error:function(error){
                                    alert("兑换"+error);
                                }
                        })     
                    }
                }
            }
        },
        // 记录
        Ji:function(){
                var that = this;
                 $.ajax({
                        url:'http://118.31.79.20:8080/Stock/order/findOrderList.do',
                        type: "post",
                        dataType: 'json',
                        data:{"uid":this.cun_deta.uid},
                        success: function(data) {
                            // console.log(data.currentPageDatas);
                           let data_ji=data.currentPageDatas;           //记录数据
                           for(var k in data_ji){
                                that.data_jilu.push(data_ji[k]);
                           }
                           $('.bor').css("display","none"); 
                        },
                        error:function(error){
                            // alert("记录"+error);
                        }
                })     
        },
        //点击填写地址 
        address:function(i){
             var that = this;
            // console.log('商品索引'+i);
            $('.bor').css("display","block"); //模态框显示出来
            this.jilu_deta.dingId  = this.data_jilu[i].id;//商品订单id
            console.log('商品id'+this.jilu_deta.dingId);
            // console.log(this.data_jilu[i].isYNA);
            
            // 判断是修改地址还是填写地址
            if(this.data_jilu[i].isYNA == "修改地址"){
                // console.log(true);
                this.jilu_deta.dingName = this.data_jilu[i].shouhuoren;
                this.jilu_deta.dingIphone =this.data_jilu[i].mobile;
                this.jilu_deta.dingBian = this.data_jilu[i].youbian;
                this.jilu_deta.dingDi = this.data_jilu[i].address;
                this.jilu_deta.dingXiang = this.data_jilu[i].area;
            }else if(this.data_jilu[i].isYNA == "填写地址"){
                // console.log(false);
                this.jilu_deta.dingName = this.data_jilu[i].shouhuoren;
                this.jilu_deta.dingIphone =this.data_jilu[i].mobile;
                this.jilu_deta.dingBian = this.data_jilu[i].youbian;
                this.jilu_deta.dingDi = this.data_jilu[i].address;
                this.jilu_deta.dingXiang = this.data_jilu[i].area;
            } 
        },    
        // 点击保存提交订单信息数据
        save:function(){
            $('.bor').css("display","none");
            // console.log(this.jilu_deta.dingId);
            // console.log('用户id'+this.cun_deta.uid);
              var that = this;
            $.ajax({
                url:'http://118.31.79.20:8080/Stock/address/updateAddress.do',
                type: "post",
                dataType: 'json',
                data:{"uid":this.cun_deta.uid,'id':this.jilu_deta.dingId,'shouhuoren':this.jilu_deta.dingName,'mobile': this.jilu_deta.dingIphone,'youbian': this.jilu_deta.dingBian,'address': this.jilu_deta.dingDi,'area':this.jilu_deta.dingXiang},
                success: function(data){
                    // console.log(data.flag);
                    if(data.flag == true){
                        alert('地址保存成功');
                        location.reload(true);           
                    }else{
                        alert('地址保存失败！');
                        that.people();
                    }
                    
                },
                error:function(error){
                    alert("兑换"+error);
                }
            })
        }
       
  }  
})